package com.study.hot.architecture.mvx.mvvm.view;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import com.study.hot.R;
import com.study.hot.architecture.mvx.mvvm.viewmodel.JZQViewModel;
import com.study.hot.databinding.ActivityJingziqiMvvmBinding;


/**
 * <pre>
 *     author : slx
 *     time   : 2020/11/21
 *     desc   : MVVM架构
 * </pre>
 */
public class MvvmJZQActivity extends AppCompatActivity {

    JZQViewModel viewModel = new JZQViewModel();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityJingziqiMvvmBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_jingziqi_mvvm);
        binding.setViewModel(viewModel);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater menuInflater = getMenuInflater();
        menuInflater.inflate(R.menu.menu_jingziqi, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
        switch (item.getItemId()) {
            case R.id.action_reset:
                viewModel.onRestartSelected();
                return true;
        }
        return super.onOptionsItemSelected(item);
    }
}
